// 用户相关操作
import request,{Method} from '@/plugins/api.js'



// 用户增加收货地址
export function addUserReceive (params) {
    return request({
      url: '/member/memberreceiveaddress/addUserReceive',
      method: Method.POST,
      data: params
    });
}

// 根据用户id获取用户收货地址
export function getUserReceiveByUserId(userId){
    return request({
        url : `/member/memberreceiveaddress/getUserReceiveByUserId/${userId}`,
        method: Method.GET,
    })
}

// 根据地址id获取用户收货地址
export function getReceiveAddressById(id){
    return request({
        url : `/member/memberreceiveaddress/getReceiveAddressById/${id}`,
        method: Method.GET,
    })
}

// 根据地址id获取用户收货地址
export function updateUserReceiveAddress(params){
    return request({
        url : `/member/memberreceiveaddress/updateUserReceiveAddress`,
        method: Method.PUT,
        data: params
    })
}

// 修改用户信息
export function editUserInfo(params){
    return request({
        url : `/member/member/editUserInfo`,
        method: Method.PUT,
        data: params
    })
}

// 检查该用户是否设置了密码
export function checkPwdStatus(userId){
    return request({
        url : `/member/member/checkPwdStatus/${userId}`,
        method: Method.GET,
    })
}

// 根据用户id修改密码
export function editPwd (params) {
    return request({
      url: '/member/member/editPwd',
      method: Method.POST,
      data: params
    });
}

// 获取用户的优惠券(分页)
export function getUserCouponByPage (params) {
    return request({
      url: '/member/membercouponrelation/getUserCouponByPage',
      method: Method.POST,
      data: params
    });
}

// 检查该用户是否收藏了该商品
export function isColletcion(userId,skuId){
    return request({
        url : `/member/membercollectspu/isColletcion/${userId}/${skuId}`,
        method: Method.GET,
    })
}

// 用户取消收藏
export function cancelCollection(userId,skuId){
    return request({
        url : `/member/membercollectspu/cancelCollection/${userId}/${skuId}`,
        method: Method.DELETE,
    })
}

// 获取用户的优惠券(分页)
export function collectProduct (params) {
    return request({
      url: '/member/membercollectspu/collectProduct',
      method: Method.POST,
      data: params
    });
}

// 获取用户收藏的商品的分页数据
export function getUserCollectionByPage (params) {
    return request({
      url: '/member/membercollectspu/getUserCollectionByPage',
      method: Method.POST,
      data: params
    });
}

// 用户添加购物车
export function addCart (params) {
    return request({
      url: '/member/membercart/addCart',
      method: Method.POST,
      data: params
    });
}

// 获取用户的购物车数据
export function getCart(memberId){
    return request({
        url : `/member/membercart/getCart/${memberId}`,
        method: Method.GET,
    })
}

// 获取购物车收藏的商品的数量
export function cartCount(memberId){
    return request({
        url : `/member/membercart/cartCount/${memberId}`,
        method: Method.GET,
    })
}

// 删除购物车项
export function deleteCartItem(memberId,skuId){
    return request({
        url : `/member/membercart/deleteCartItem/${memberId}/${skuId}`,
        method: Method.DELETE,
    })
}

// 去购物车页面
export function goCart(userInfo){
    return request({
        url : `/member/membercart/goCart/${userInfo}`,
        method: Method.GET,
    })
}

// 购物车全选
export function checkAll(memberId,check){
    return request({
        url : `/member/membercart/checkAll/${memberId}/${check}`,
        method: Method.GET,
    })
}

//购物车全选 根据商铺
export function checkAllByStore (params) {
    return request({
      url: '/member/membercart/checkAllByStore',
      method: Method.PUT,
      data: params
    });
}

//购物车全选 根据商铺
export function checkSingleItem (params) {
    return request({
      url: '/member/membercart/checkSingleItem',
      method: Method.PUT,
      data: params
    });
}

//改变购物车项选中的数量
export function changeCartItemNum (params) {
    return request({
      url: '/member/membercart/changeCartItemNum',
      method: Method.PUT,
      data: params
    });
}

// 根据params参数删除购物车项
export function deleteCartItemByMap (params) {
    return request({
      url: '/member/membercart/deleteCartItemByMap',
      method: Method.DELETE,
      data: params
    });
}

// 清空购物车
export function clearCart (memberId) {
    return request({
      url: `/member/membercart/clearCart/${memberId}`,
      method: Method.DELETE,
    });
}

// 获取当前购物车页的总价
export function getCartPriceDetail(memberId){
    return request({
        url : `/member/membercart/getCartPriceDetail/${memberId}`,
        method: Method.GET,
    })
}

// 删除用户的收货地址
export function deleteUserReceiveAddress (id) {
    return request({
      url: `/member/memberreceiveaddress/deleteUserReceiveAddress/${id}`,
      method: Method.DELETE,
    });
}

// 设置默认收货地址
export function setDefaultAddress(params){
    return request({
        url : `/member/memberreceiveaddress/setDefaultAddress`,
        method: Method.PUT,
        data: params
    })
}

// 获取用户中心的优惠券分页数据
export function gerUserCenterCouponPage (params) {
    return request({
      url: '/member/membercoupon/gerUserCenterCouponPage',
      method: Method.POST,
      data: params
    });
}

// 获取商品结算详情(购物车方式进行结算)
export function getGoodPayDetailTypeCART (params) {
    return request({
      url: '/member/membercart/getGoodPayDetailTypeCART',
      method: Method.POST,
      data: params
    });
}